package com.gec.domain;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author Aniki
 * @date 2021-12-23
 */
public class User {
	private String id;
	private String username;
	private String password;
	private String nickName;
	private String email;
	private String no;
	private String sex;
	private String createDate;
	private Dept dept;
	private Set<Role> roles = new HashSet();
	
	public User(String id, String username, Dept dept, Role role) {
		this.id = id;
		this.username = username;
		this.dept = dept;
		roles = new HashSet();
		roles.add(role);
	}

	/**
	 * User改造   2021-12-14
	 * 添加deptId
	 * 设置get、set方法
	 * 新增getPrimaryRole方法
	 * 获取主功能
	 * */
	private String deptId;

	public String getDeptId(){
		return this.deptId;
	}
	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}


	public  Role getPrimaryRole(){
		Iterator<Role> it = roles.iterator();
		if (it.hasNext()) {
			return it.next();
		}
		return null;
	}




	public User() {

	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getNickName() {
		return nickName;
	}
	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getNo() {
		return no;
	}
	public void setNo(String no) {
		this.no = no;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getCreateDate() {
		return createDate;
	}
	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}
	public Dept getDept() {
		return dept;
	}
	public void setDept(Dept dept) {
		this.dept = dept;
	}
	public Set<Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
	
	@Override
	public String toString() {
		return "User [id=" + id + ", username=" + username + ", password=" + password + ", nickName=" + nickName
				+ ", email=" + email + ", no=" + no + ", sex=" + sex + ", createDate=" + createDate + "]";
	}

}
